package Thread;
//Thread自带的关键字打断
public class Demo8 {
    public static void main(String[] args) throws InterruptedException {
        Thread t=new Thread(()->{
            while (!Thread.currentThread().isInterrupted()){
                System.out.println("t进程");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                    //唤醒sleep有3种操作
                    //1.不管它，继续执行t线程
                    //2.立即执行打断
                    //break;
                    //3.进行一些其他操作
                }
            }
        });
        t.start();
        System.out.println("main进程");
        Thread.sleep(5000);
        System.out.println("t进程打断");
        t.interrupt();
    }
}
